package com.ahzx.area.service.impl;

import com.ahzx.area.mapper.AhCityDistrictMapper;
import com.ahzx.area.response.AreaInfo;
import com.ahzx.area.service.AhCityDistrictService;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 区域信息业务实现层
 * @Author syg
 * @Date 2021/4/28 19:10
 * @Desc To be or not to be,that is a question.
 */
@Service
public class AhCityDistrictServiceImpl implements AhCityDistrictService {

    @Value("${areaId}")
    private String areaId;

    @Autowired
    private AhCityDistrictMapper ahCityDistrictMapper;

    @Override
    public List<AreaInfo> selectAhCityDistrictList() {
        return ahCityDistrictMapper.selectAhCityDistrictList(areaId).stream().map(entity ->{
            AreaInfo areaInfo = new AreaInfo();
            areaInfo.setAreaId(String.valueOf(entity.getId()).substring(2));
            areaInfo.setAreaName(entity.getName());
            return areaInfo;
        }).collect(Collectors.toList());
    }

}
